import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import md5 from 'js-md5';
Vue.prototype.$md5 = md5;
Vue.use(ElementUI);
Vue.config.productionTip = false

router.beforeEach((to,from,next) =>{//to,from,next
  if(from.meta.from == to.meta.from&&from.meta.son){//是不是同个顶级菜单下面的路由
    if(from.meta.son===to.meta.son) {//同个顶级菜单下不同路由允许跳转
      next();
    }else {//不允许子路由再跳回同一顶级路由
      next(from.path);
    }
  }else {
    next();
  }
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
